<template>
  <div>
    <TypeNav />
    <ListContainer />
    <Recommend />
    <Rank />
    <Like />
    <!-- 父子组件通信: Floor这个组件内部没有发送请求，数据是由父组件Home给的 -->
    <Floor v-for="(floor, index) in getfloorList"
           :key="floor.id"
           :list="floor" />
    <Brand />
  </div>
</template>

<script>
// 引入其余静态组件
import ListContainer from '@/pages/Home/ListContainer'
import Recommend from '@/pages/Home/Recommend'
import Rank from '@/pages/Home/Rank'
import Like from '@/pages/Home/Like'
import Floor from '@/pages/Home/Floor'
import Brand from '@/pages/Home/Brand'
import { mapState } from 'vuex'
export default {
  name: 'Home',
  components: {
    ListContainer,
    Recommend,
    Rank,
    Like,
    Floor,
    Brand
  },
  mounted() {
    this.$store.dispatch('getFloorList')
  },
  computed: {
    ...mapState({
      // 通过mapState辅助函数从仓库中拿到floor数据
      getfloorList: state => state.home.getfloorList
    })
  }
};
</script>

<style scoped>
</style>
